<script setup lang="ts">
import { ref } from "vue";
import PicUpload from "@/components/base-ui/editor/picUpload.vue";
import { getqualityandreliability, changequalityandreli } from '@/api/qualityreliability'
import { message } from "@/utils/message";


defineOptions({
  name: "Statement"
});



const activeNames = ref('');
const id = ref('');
const updatelValFn = (e) => {
  activeNames.value = e
}

const tapSave = () => {
  changequalityandreli({ description: activeNames.value, "id": id.value }
  ).then(res => {
    message("修改成功", {
      type: "success"
    });
  })
}

const loading = ref(false)
const getData = () => {
  loading.value = true
  getqualityandreliability().then(res => {
    res.result.forEach(e => {
      if (e.name === '环境声明') {
        activeNames.value = e.description
        id.value = e.id
      }
    });
  }).finally(() => {
    loading.value = false
  })
}

getData()
</script>

<template>
  <div v-loading="loading">
    <el-card shadow="never" v-if="!loading">
      <PicUpload :htmlVal="activeNames" @updatelVal="updatelValFn" />
    </el-card>
    <div class="flex justify-end pr-[50px]">
      <el-button type="success" class="mt-[30px]" @click="tapSave">保存</el-button>
    </div>
  </div>
</template>

<style lang="scss" scoped></style>
